package A1;

class GridType{
   private static final int SIZE = 50;
   private static char grid[][] = new char[SIZE][SIZE];

   public static void assignSpace(){
            for(int x=0;x<23;x++){ //print characters inside grid array
                for(int i = 0;i<24;i++){
                    grid[x][i]= ' ';
                }
            }
   }

   public static void assignStreet(){

        for(int x=0;x<8;x++){
         grid[8][x] = '-';
         grid[12][x] = '-';
        }
        for(int i=14;i<24;i++){
         grid[8][i] = '-';
         grid[12][i] = '-';
        }
        for(int x=0;x<8;x++){
         grid[x][8] = '|';
         grid[x][13] = '|';
        }
        for(int i=13;i<24;i++){
         grid[i][8] = '|';
         grid[i][13] = '|';
        }

    }

   public void assignHLight(boolean gridPrintHLightStatus){
       if (gridPrintHLightStatus == true){
           grid[8][8] = 'R';
       }
       else if (gridPrintHLightStatus == false){
            grid[8][8] = 'G';
        }
   }

   public void assignVLight(boolean gridPrintVLightStatus){
       if (gridPrintVLightStatus == true){
           grid[8][13] = 'R';
       }
       else if (gridPrintVLightStatus == false){
            grid[8][13] = 'G';
        }
   }

   public static void setCarPos(char car, int pos,int lane, boolean v){
     if (v == true){ //vertical car
       grid[pos][lane] = car;
       if (pos - 1 >= 0)
         {
             grid[pos - 1][lane] = ' ';
         }
     }
     else if (v == false){ //horizontal car
       grid[lane][pos] = car;
       if (pos - 1 >= 0)
         {
             grid[lane][pos - 1] = ' ';
         }
     }
   }

/*   public static void changeLane(char car, int pos,int lane, boolean v){
     if (v == true){ //vertical car
       grid[pos][lane] = car;
       grid[pos][lane-1] = ' ';
     }
     else if (v == false){ //horizontal car
       grid[lane][pos] = car;
       grid[lane-1][pos] = ' ';

     }
   }*/

   public static char getGrid(int h, int v){
       return grid[h][v];
   }

}